#include "widget.h"
#include "ui_widget.h"
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    ui->comboBox->addItem("巨无霸");
    ui->comboBox->addItem("双层牛堡");
    ui->comboBox->addItem("香辣鸡腿堡");

    ui->comboBox_2->addItem("大叔条");
    ui->comboBox_2->addItem("小薯条");
    ui->comboBox_2->addItem("中薯条");

    ui->comboBox_3->addItem("可乐");
    ui->comboBox_3->addItem("雪碧");
    ui->comboBox_3->addItem("牛奶");

    ui->spinBox->setRange(1, 6);
    ui->spinBox_2->setRange(1, 6);
    ui->spinBox_3->setRange(1, 6);

    ui->spinBox->setValue(1);
    ui->spinBox_2->setValue(1);
    ui->spinBox_3->setValue(1);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    qDebug() << "点餐为: " << ui->comboBox->currentText() << ":" << ui->spinBox->value() << ", "
                          << ui->comboBox_2->currentText() << ":" << ui->spinBox_2->value() << ", "
                          << ui->comboBox_3->currentText() << ":" << ui->spinBox_3->value();
}

void Widget::on_pushButton_cal_clicked()
{
    QDateTime timeOld = ui->dateTimeEdit->dateTime();
    QDateTime timeNew = ui->dateTimeEdit_2->dateTime();

//    int days = timeOld.daysTo(timeNew);
//    qDebug() << "间隔 " << days << " 天";

    int sec = timeOld.secsTo(timeNew);
    int hours = (sec / 3600) % 24;
    int days = (sec / 3600) / 24;
    ui->label_date->setText(QString("间隔") + QString::number(days) + QString("天，小时") + QString::number(hours));
}
